n = input()
c = 0
while len(n) > 1:
n = str(sum(map(int,n)))
c += 1
print(c)
#include <iostream>
#include <queue>
using namespace std;
int sumOfDigits(int x) {
int sum = 0;
while (x > 0) {
sum += x % 10;
x /= 10;
}
return sum;
}
int sumOfDigitsString(string x) {
int sum = 0;
int len = x.length();
for (int i = 0; i < len; ++i) {
sum += x[i] - '0';
}
return sum;
}
void solve () {
string x;
cin >> x;
if (x.length() < 2) {
cout << 0;
return;
}
int newX = sumOfDigitsString(x);
int counter = 1;
while ( newX > 9 ) {
newX = sumOfDigits(newX);
++counter;
}
cout << counter;
}
int main() {
solve();
return 0;
}
Numbers in a matrix | Sequences |
Split houses | Divisible |
Three primes | Coprimes |
Cost of balloons | One String No Trouble |
Help Jarvis! | Lift queries |
Goki and his breakup | Ali and Helping innocent people |
Book of Potion making | Duration |
Birthday Party | e-maze-in |
Bricks Game | Char Sum |
Two Strings | Anagrams |
Prime Number | Lexical Sorting Reloaded |
1514A - Perfectly Imperfect Array | 580A- Kefa and First Steps |
1472B- Fair Division | 996A - Hit the Lottery |
MSNSADM1 Football | MATCHES Playing with Matches |
HRDSEQ Hard Sequence | DRCHEF Doctor Chef |